package bb.lanxing.manager;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import bb.lanxing.App;
import bb.lanxing.R;
import bb.lanxing.activity.base.WebActivity;
import bb.lanxing.activity.deeplink.DeepLinkPathConstants;
import bb.lanxing.common.messager.MessageSender;

import kotlin.Unit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;

public final class DeepLinkManager {
    public static final Companion Companion = new Companion(null);

    public static final class Companion {
        public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        private final void openFile(Context context, Uri uri) {
//            BuildersKt__Builders_commonKt.launch$default(XossCoroutineScopeKt.getXossCoroutineScope(), null, null, new DeepLinkManager$Companion$openFile$1(uri, context, null), 3, null);
        }

        public final void dispatch(Context context, Intent intent) {
            Intrinsics.checkNotNullParameter(context, "context");
            if (intent != null) {
                Uri data = intent.getData();
                Uri data2 = intent.getData();
                String str = null;
                String scheme = data2 != null ? data2.getScheme() : null;
                Uri data3 = intent.getData();
                if (data3 != null) {
                    str = data3.getHost();
                }
                Uri data4 = intent.getData();
                if (data4 != null) {
                    data4.getQuery();
                }
                if (scheme == null) {
                    return;
                }
                switch (scheme.hashCode()) {
                    case -2057870771:
                        if (!scheme.equals(DeepLinkPathConstants.SCHEME_APP_LANXING)) {
                            return;
                        }
                        if (Intrinsics.areEqual(str, DeepLinkPathConstants.HOST)) {
//                            ARouter.getInstance().build(data).navigation(context, new NavigationCallback() {
//                                @Override
//                                public void onArrival(Postcard postcard) {
//                                }
//
//                                @Override
//                                public void onFound(Postcard postcard) {
//                                }
//
//                                @Override
//                                public void onInterrupt(Postcard postcard) {
//                                }
//
//                                @Override
//                                public void onLost(Postcard postcard) {
//                                }
//                            });
                            return;
                        } else if (!Intrinsics.areEqual(str, DeepLinkPathConstants.HOST_RESPONSE)) {
                            return;
                        } else {
                            MessageSender messageSender = App.getContext().getMessageSender();
                            DeepLinkData deepLinkData = new DeepLinkData(scheme);
                            deepLinkData.setRawUri(data);
                            deepLinkData.setHost(str);
                            deepLinkData.setQuery(deepLinkData.getQuery());
                            Unit unit = Unit.INSTANCE;
                            messageSender.sendMessage(R.id.msg_app_deep_link_response, deepLinkData);
                            return;
                        }
                    case 3143036:
                        if (!scheme.equals(DeepLinkPathConstants.SCHEME_FILE)) {
                            return;
                        }
                        DeepLinkManager.Companion.openFile(context, data);
                        return;
                    case 3213448:
                        if (!scheme.equals("http")) {
                            return;
                        }
                        WebActivity.start(context, "", String.valueOf(data));
                        return;
                    case 99617003:
                        if (!scheme.equals("https")) {
                            return;
                        }
                        WebActivity.start(context, "", String.valueOf(data));
                        return;
                    case 951530617:
                        if (!scheme.equals("content")) {
                            return;
                        }
                        DeepLinkManager.Companion.openFile(context, data);
                        return;
                    default:
                        return;
                }
            }
        }

        public static final class DeepLinkData {
            private String host;
            private String query;
            private Uri rawUri;
            private final String scheme;

            public static /* synthetic */ DeepLinkData copy$default(DeepLinkData deepLinkData, String str, int i, Object obj) {
                if ((i & 1) != 0) {
                    str = deepLinkData.scheme;
                }
                return deepLinkData.copy(str);
            }

            public final String component1() {
                return this.scheme;
            }

            public final DeepLinkData copy(String scheme) {
                Intrinsics.checkNotNullParameter(scheme, "scheme");
                return new DeepLinkData(scheme);
            }

            public boolean equals(Object obj) {
                if (this == obj) {
                    return true;
                }
                return (obj instanceof DeepLinkData) && Intrinsics.areEqual(this.scheme, ((DeepLinkData) obj).scheme);
            }

            public int hashCode() {
                return this.scheme.hashCode();
            }

            public String toString() {
                return "DeepLinkData(scheme=" + this.scheme + ')';
            }

            public DeepLinkData(String scheme) {
                Intrinsics.checkNotNullParameter(scheme, "scheme");
                this.scheme = scheme;
            }

            public final String getScheme() {
                return this.scheme;
            }

            public final Uri getRawUri() {
                return this.rawUri;
            }

            public final void setRawUri(Uri uri) {
                this.rawUri = uri;
            }

            public final String getHost() {
                return this.host;
            }

            public final void setHost(String str) {
                this.host = str;
            }

            public final String getQuery() {
                return this.query;
            }

            public final void setQuery(String str) {
                this.query = str;
            }
        }
    }
}
